home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / utilities / utility_04 / changefsi / !ChangeFSI / FSIinfo < prev    next >
Encoding:
Text File  |  1992-05-11  |  49.2 KB  |  963 lines

  1.      ChangeFSI: Colour Image Processing Using the 256 colour modes
  2.  
  3. Archimedes computers have full colour display capabilities built into them
  4. as standard. However, compared with the hardware found in larger
  5. workstations, the facilities provided have been carefully reduced (in order
  6. to make them cheap enough to fit all the time). So the precision of the
  7. digital to analogue converters is only 4 bits (instead of 8) and the colour
  8. palette only has 16 entries (instead of 256).
  9.  
  10. The VIDC 256 colour mode
  11. =========================
  12.  
  13. Has 4 direct bits (top 2 green, top red and blue) plus 4 palette look up
  14. bits which affect the remaining DAC bits. This therefore gives a choice of
  15. 256 colours from 4096, but the choice is not a free one in that the 4 direct
  16. bits are always connected: this leaves only 256 selections available from
  17. the 4096 colour range. To repeat: there are 256 simultaneous colours in a
  18. selection out of 4096 colours, where there are only 256 "legal" selections.
  19.  
  20. There are "optimal" selections. An optimal selection is one which covers the
  21. entire R, G, B colour cube (i.e. 0-fullscale for each of the colours) and
  22. can thus be dithered to from any picture (if one considers picture's colour
  23. range as an arbitrary volume in the colour cube, then you can dither/display
  24. a picture accurately if and only if the volume covered by the available
  25. colours encloses the picture's). The optimal selection used for the RISC OS
  26. 256 colour mode palette contains 2 most significant bits of Red, 2 most
  27. significant bits of Green and 2 most significant bits of Blue, with the last
  28. 2 bits controlling the 2 least significant bits in parallel ("adds white" to
  29. a colour). Thus peak R, G, B is obtained (without side effects if varied
  30. simultaneously, with a side effect if peak R (say) alone is required). A
  31. correctly designed error diffusion dither algorithm can display pictures
  32. with very high fidelity. [note that dithering all pictures with a single
  33. palette permits their display simultaneously on the screen, also note that
  34. dithering to a fixed palette is much quicker than selecting a palette
  35. first!]
  36.  
  37. One can also program the system for a large number of n bits per colour
  38. modes, with the n bits starting at the most significant end of the colour
  39. range. For example 4 bits of green, 3 bits of red and 1 bit of blue. The
  40. constraints are:
  41.      2 <= nGreen <= 4
  42.      1 <= nRed   <= 4
  43.      1 <= nBlue  <= 4
  44.      (and nRed+nBlue+nGreen=8)
  45. Modes like these are often useful for real time solid modelling (where the
  46. expense of dithering with error diffusion (circa 100 cycles per pixel)
  47. cannot be afforded). These selections are non-optimal: the colour cube is
  48. not completely spanned.
  49.  
  50. Displaying A Picture
  51. ====================
  52.  
  53. Since a colour in the 256 colour mode can be such a complicated thing, with
  54. varying capability of spanning the colour cube and an unknown accuracy,
  55. there is a RISC OS standard way of specifying a colour you wish to draw with
  56. using 8 bits for R, G and B components. A call to the operating system
  57. converts this to the nearest colour and new objects can be drawn.
  58.  
  59. Where the object to be drawn is a previously generated picture, the modules
  60. "SpriteExtend" (in the ROM) and "ColourTrans" (in the !System directory) in
  61. RISC OS provide some capabilites for displaying pictures in different screen
  62. modes. ColourTrans can look at the palette which a sprite uses and return a
  63. list of the equivalent 'closest' colours in the current screen mode.
  64. SpriteExtend can paint sprites using the list of equivalent colours and can
  65. change the size of the image into the bargain. This is all very well for
  66. simple pictures or pictures created directly for a particular mode, but what
  67. happens for more detailed information or pictures from other sources with
  68. resolution not matched by the Archimedes hardware?
  69.  
  70. Also the above facilities are rather basic: ColourTrans makes no effort to
  71. use dithering (the practise of putting patterns of different coloured pixels
  72. together to represent other colours) and SpriteExtend simply discards
  73. additional information if reducing the picture in size (and together they
  74. make no attempt to enhance the picture when making it larger). The reason
  75. for these shortcomings is quite simple: speed. The algorithm used in
  76. ChangeFSI uses 105 ARM instructions per pixel - and that's apart from any
  77. instructions used to read the image in, change its size and write the result
  78. out. For comparison, the normal sprite plot takes only one instruction per
  79. pixel (4 instructions for four 8 bit pixels). Processing a MODE 15 picture
  80. thus uses up too many seconds of ARM cpu time to imagine it as part of the
  81. interactive desktop.
  82.  
  83. So what does ChangeFSI do to make the situation better? And why does it take
  84. so long? One can immediately draw up some desirable properties for any
  85. solution to the image changing problem:
  86.  
  87. (1) Maximising the volume of the colour cube. Colour represented in the Red,
  88. Green and Blue computer graphics system can be thought of as a point in a 3D
  89. cube whose axes are the red, green and blue values. Whatever clever
  90. approximations, dithering or error diffusion techniques are used, the colour
  91. volume spanned by the r, g and b axes in the target should be large enough
  92. to contain the source volume. If not, then the picture will appear faded in
  93. some way compared to the original ("the red doesn't seem quite the same").
  94. For a single picture a colour volume only as large as the input could be
  95. chosen; alternatively for an arbitrary set of input pictures, the colour
  96. volume on the output system has to be made as large as possible. Where
  97. animation is required the colour volume has to be consistent for all the
  98. pictures. When generating the largest volume, it is important to use the
  99. system hardware to the limit: for example, if one has two bits of control
  100. over the Archimedes 4 bit D to A converters, the largest range is covered by
  101. values 0, 5, 10 and 15 (rather than 0, 4, 8 and 12).
  102.  
  103. (2) Giving hue consistency at different saturations. For example, with a
  104. palette with different numbers of bits of r, g and b it may be impossible to
  105. have a consistent set of colours representing derived colours at different
  106. levels of intensity. Shades of white and secondary colours (cyan, magenta
  107. and yellow) are particularly difficult.
  108.  
  109. (3) Working with the multi-tasking desktop. Acorn are asking for all new
  110. software to be built on the multitasking system. This implies that the
  111. palette should not be changed (or that the agreement of all programs
  112. currently running is obtained first).
  113.  
  114. The desktop (default) palette in the 256 colour modes (e.g. modes 13, 15,
  115. 21, 24 and 28) is quite well designed. It does have the properties of (1)
  116. and (2) (it even has 16 shades of grey) and automatically satisfies (3). It
  117. is used by many Acorn programs (Draw, Paint) and by external programs
  118. (Euclid, ProArtisan, Atelier, ..) to great effect and is a safe choice for
  119. ChangeFSI. There are three ways ChangeFSI can choose a colour:
  120.  
  121. (a) a method which derives values for r, g, b and tint algorithmically (no
  122. suffix) (suitable only for the default RISC OS 256 colour palette)
  123.  
  124. (b) search the palette for the closest colour (r suffix) (slow!)
  125.  
  126. (c) a 4096 entry table indexed by r, g and b which gives the answer (t
  127. suffix)
  128.  
  129. ASIDE: the closest colour is chosen such that the distance between the true
  130. colour and the choice is minimised in the colour cube space. Since the human
  131. eye is more sensitive to green, then red and lastly blue, the distance
  132. function is weighted 10, 3 and 1 in green's favour.
  133.  
  134. With the 16 colour modes (e.g. modes 9, 12, 16, 20 and 27) the default
  135. palette does not satisfy (1) and (2) unless the output is purely shades of
  136. grey - ChangeFSI can use either 8 greys (for the desktop) or 16 greys (out
  137. of the desktop or with the desktop palette altered to provide 16 greys). For
  138. colour representation, ChangeFSI can either:
  139.  
  140. (a) use 1 bit of red, 1 bit of green and 1 bit of blue (i.e. the standard 8
  141. digital colours Black, Red, Green, Blue, Yellow, Magenta, Cyan and White).
  142. This spans the colour cube and is hue consistent, but doesn't use the full
  143. range of bits provided in the format. ColourTrans can map this to the
  144. desktop with the standard palette with fair success, except for the lack of
  145. magenta (full red+full blue) in the palette. A better result can be achieved
  146. by setting 6 of the colours in the palette to red, green, yellow, blue,
  147. magenta and cyan. Since ColourTrans will map the colours anyway, it doesn't
  148. matter which 6, but the most consistent values are 8=blue, 9=yellow,
  149. 10=green, 11=red, 13=cyan, 14=magenta (leaving 0-7, 12 and 15 unchanged).
  150. This option is selected by a "d" (digital RGB) suffix to the program's mode
  151. argument.
  152.  
  153. or (b) search the palette for the closest colour (r suffix) [ChangeFSI needs
  154. to be in the 16 colour mode in order to read the palette]
  155.  
  156. With the 4 colour modes (e.g. modes 8, 11, 19 and 26) ChangeFSI is really
  157. pushed. Shades of grey output is done with the 0, 5, 10, 15 level palette.
  158. But how can colour be done? For example, each pixel can display only one of
  159. (say) black, red, green or blue. This fails to span the colour cube (it does
  160. only half of it), however, so black, cyan, magenta and yellow are used
  161. instead. The rest has to be left to luck: there is no way it can approximate
  162. to pure shades of red, green or blue. 4 bit colour pictures can be seen on
  163. the desktop in 16 colour modes with the above palette or in 256 colour
  164. modes. This option is by a "c" suffix. If you can provide a better palette,
  165. then ChangeFSI can use it with the "r" suffix search method.
  166.  
  167. With 2 colour modes (e.g. modes 0, 18, 23 and 25) pixels are either ON or
  168. OFF, ChangeFSI will only do shades of grey output.... However, the method
  169. used can be varied (see later).
  170.  
  171. So that's the canvas ChangeFSI has to work on. How does it display the input
  172. range of colours on these outputs? The answer is, as stated above,
  173. dithering: the process of approximating intensity variations with patterned
  174. areas. There are two basic types of dithering technique: that used to print
  175. colour magazines and newspaper photographs "clustered dot dither" - the size
  176. of the dot of ink gives the intensity; and that used on dot matrix displays,
  177. for example the grey level patterns used by 1 bit per pixel mode on the
  178. desktop "dispersed dot dither" where the average number of dots in the area
  179. gives the intensity.
  180.  
  181. Why does the world need two different techniques? Well, different devices
  182. reproduce pixels differently. The "ideal square" pixels produced by an LCD
  183. are perfect for dispersed dot dither; a CRT produces a gaussian spot (a
  184. circle or ellipse which decays in intensity towards the edges) instead of a
  185. square - dispersed dot dither works well; a dot matrix impact printer or a
  186. "write black" laser printer produce large dots (diameter at least SQR(2)
  187. over unit pixel square) and thus make pictures too dark if dispersed dot
  188. dither is used; a "write white" laser printer prints negative "white dots"
  189. on a black field and thus "caves in" the sides of pixels making pictures too
  190. white with dispersed dot dither. Clustered dot dither reduces the effects of
  191. mis-sized pixels by ensuring they are adjacent (and thus the error is
  192. confined to the periphery of the shape) but this does have a cost in poorer
  193. resolution.
  194.  
  195. Since ChangeFSI's colour or greyscale output is to CRTs (or LCDs in some
  196. distant future) it automatically uses a dispersed dot dither. Monochrome
  197. output could be for the screen or for a printer: the user can select between
  198. dispersed and clustered methods by adding a various suffices ("c", "d" or
  199. "t") to the mode number for clustered output. For "c" the algorithm (due to
  200. Robert L Gard, 1976) approximates tones in the range 0..16 (17 levels) by
  201. using 0..16 "on" pixels in a 4 by 4 cell. For "d" the algorithm (developed
  202. by me, but similar to Gard's) approximates tones in the range 0..4 (5
  203. levels) by using 0..4 "on" pixels in a 2 by 2 cell. For "t" the algorithm
  204. (ditto as "d") approximates tones in the range 0..9 (10 levels) by using
  205. 0..9 "on" pixels in a 3 by 3 cell. The "on" pixels are carefully chosen to
  206. provide: (a) symmetry of white/black and black/white patterns (b) diagonally
  207. oriented dot grid. The diagonal angle reduces the eye's ability to see the
  208. rectangular patterns produced. The various sizes of the halftone cell allow
  209. some trade off between representing the tonal values correctly and loss of
  210. resolution. Start with "c" and progress to "t" and then "d" if the
  211. resolution is not acceptable.
  212.  
  213. ChangeFSI can generate reasonable pictures on "write black" printers with a
  214. dispersed dot dither by using the "-black" parameter; however images
  215. produced like this do not photocopy at all well (the photocopier makes the
  216. dots blacker again!). The parameter to -black (default value 32, range
  217. 0..128) tells ChangeFSI how much larger than the ideal square pixel the dots
  218. produced by the printer are - 128 corresponds to an inked dot covering four
  219. times the area of the ideal black square pixel (and this will generally mean
  220. ChangeFSI produces an entirely white output!). Values above 64 give rather
  221. poor results on some pictures but may be worth experimenting with. The
  222. default is 32, a dot covering 50% more area than the square pixel (the
  223. minimum circle enclosing the pixel square). Some printers produce dots of
  224. (pseudo-randomly) varying sizes and black correction may not help with these
  225. (the picture looks "noisy") in which case use one of the clustered output
  226. methods. -black correction makes pictures on the screen look very pale,
  227. since, if anything, black pixels on screen are smaller than the ideal
  228. square.
  229.  
  230. [aside: to print these pictures, you need a method which copies the pixels
  231. ChangeFSI has made exactly to those of the output device. Using !Paint,
  232. scale X and Y by 90:300 for a 300dpi printer.]
  233.  
  234. In all cases, an approximation to a colour will produce an error (which
  235. might possibly be zero if ChangeFSI is very lucky). ChangeFSI tracks these
  236. errors and ensures that over wide areas there is no overall error using a
  237. technique called "error diffusion", first devised by R W Floyd and L
  238. Steinberg in 1975. In this technique the approximation is made and the error
  239. distributed to nearby pixels in the following ratios:
  240.  
  241.                 current pixel   7/16 of error
  242. 3/16 of error   5/16 of error   1/16 of error
  243.  
  244. ChangeFSI gets some of its name from Floyd and Steinberg. Additionally,
  245. ChangeFSI scans through the picture in a serpentine fashion, doing a row of
  246. pixels left to right followed by the next row right to left. This reduces
  247. the probability of regular patterns which the eye is sensitive to. The final
  248. I of the name is for Integer: ChangeFSI does all its work in 32 bit fixed
  249. point integer arithmetic (with the point at bit 28) instead of floating
  250. point. Dithering can be turned off using using "Disable Dithering" on the
  251. Processing dialogue ("-nodither" on the command line) which at least allows
  252. you to see how well it does!
  253.  
  254. The conversion from one colour range to another is made at the same time as
  255. a change in size of the image. Size is changed by ratios of areas between
  256. the input and output: the total weight of r, g, and b in the source area is
  257. calculated using the fixed point arithmetic and this result is then
  258. approximated to the output using the error diffusion to preserve information
  259. (for example, consider halving in size an image with adjacent pixels of
  260. intensities 1 and 2; the output pixel needs to be value 1.5, so the 0.5
  261. error is sent to adjacent pixels to keep the overall colour the same). The
  262. size change is expressed as a ratio of output to input (e.g. 40:20) which
  263. ChangeFSI reduces to the smallest possible terms (2:1 in this case) so that
  264. you are free to give values like 256:512 if that's what you mean! Size
  265. change is either both x and y (if one ratio is given) or separate x and y
  266. (if two ratios are given). Note that the size of a RISC OS pixel is known,
  267. so changing from (say) mode 21 to (say) mode 13 does not need any additional
  268. specified scaling. The full size output for mode 21 is the reference, so
  269. scale to 640 by 512. A common scaling is to fill the output sprite with the
  270. input and an "=" parameter to x and/or y ratios will do this without ever
  271. having to know the size of the input. Simply omitting the fractional part
  272. causes ChangeFSI to put in the source size, thus giving output which is
  273. the specified number of pixels in size.
  274.  
  275. Conversion from colour to monochrome shades of grey is done with the CIE
  276. luminance weights for r, g and b (0.299, 0.587, 0.114) which is the standard
  277. conversion for broadcast television. These values can be altered using the
  278. -red, -green and -blue commands and allow different weightings for
  279. conversion to monochrome to be tried, this also allows selection of an image
  280. composed of only some of the colours (e.g. -red1 -green0 -blue0) in making a
  281. black and white image.
  282.  
  283. ChangeFSI can take any RISC OS sprites (2, 4, 16 or 256 colours). If there
  284. is a palette it will be used, otherwise the standard 2, 4, 16 and 256 colour
  285. desktop palettes are used.
  286.  
  287. ChangeFSI is both a command line driven program and a desktop application.
  288. The file !Help describes how to use the application from the desktop, if you
  289. need to use the program as a command line driven program you will need to
  290. have it in the library (or on run$path) and press f12 to get out of the
  291. desktop. The file "FSIuse" describes the parameters concisely. The program
  292. selects mode 0 when run from the command line when doing any work in order
  293. to speed up processing (this can be disabled with -nomode). It may also be a
  294. good idea to RMFaster BASIC. An hourglass %age processed figure is displayed
  295. (this may run through twice for some of the more expensive options). The
  296. program reads the source image from disc and builds the output in memory,
  297. having claimed some from the system.
  298.  
  299. In addition to strictly converting the source image, ChangeFSI can also
  300. process it. A trivial option is "-info": ChangeFSI will tell you what it is
  301. doing (a good way of finding out what the source image actually is, and how
  302. the scaling turns out!). Similarly trivial are -vflip and -hflip - the
  303. picture can be produce upside down and left/right reversed. Not so trivial
  304. is -rotate, which will rotate the image by 90 degrees (that is, an anti-
  305. clockwise quarter turn). -rotate- rotates by -90 degrees (clockwise quarter
  306. turn).
  307.  
  308. Sometimes useful is "-nosize": ChangeFSI can read pixel size information
  309. from the source image (if present) or guess it (e.g. if there are less than
  310. 320 by 256 pixels in a source image, ChangeFSI assumes the pixels are the
  311. same size as MODE 13's [45 per inch]) or derive it from other information
  312. and scale the output image (composed of RISC OS square or 1:2 sized pixels)
  313. appropriately. -nosize stops this from happening. [this seems particularly
  314. relevant on formats like TIFF or IFF where the pixel size is specified *but
  315. may be wrong*] Using -info will display the pixel ratios which ChangeFSI is
  316. using - a combination of the size guess, the output pixel size and any
  317. deliberate scaling. "-noscale" turns off the output scaling as well.
  318.  
  319. The simplest image processing option is "-range" which will expand the
  320. dynamic range of the input picture so that it fills the available area (not
  321. a good option for animated sequences unless all source images possess the
  322. same range). Since r, g, b are processed by the same amount, -range
  323. preserves the colour of pixels in coloured pictures.
  324.  
  325. A useful option for output intended for the screen only is Gamma correction.
  326. CRT displays do not have a simple linear relationship between brightness of
  327. the spot and input voltage: instead of brightness = const * voltage, the
  328. response is brightness = const * voltage ^ (1/gamma). In the TV industry,
  329. gamma has been standardised as 2.2, but there is wide variation in the
  330. computer industry: the monitor's response will vary depending on what make
  331. it is and how it is adjusted. Low values of gamma (0 to 1) make colours
  332. darker and high values (above 1) make colours lighter with the effects being
  333. particularly noticeable on dim colours. "-gamma" uses the default of 2.2,
  334. and it can be set by "-gamma1.5" say. Gamma correction is most relevant when
  335. its known that the input has a linear intensity (input from a scanner or
  336. from another computer with more bits per colour component than the
  337. Archimedes).
  338.  
  339. A more complex primitive is "-equal" which performs "histogram equalisation"
  340. on the image. This makes the histogram of level versus number of points at
  341. that level as flat as possible giving full use of the number of colours
  342. available. -equal is a very harsh primitive, even on monochrome inputs it
  343. can produce an inferior picture; while on colour pictures it can distort the
  344. colour of each point (since r, g, b are computed separately). But -equal can
  345. often recover a picture that is otherwise completely useless or expose
  346. information locked in a small part of the input scale.
  347.  
  348. Image colours may be inverted with the -invert option. Which may be fun in
  349. colour but is rarely useful! However, monochrome images frequently need
  350. inverting, especially one bit per pixel sources.
  351.  
  352. A more powerful option is "-sharpen" which enhances the edges of objects in
  353. the picture: this is very useful since the dithering process inevitably
  354. smears information over the display. Pre-sharpening the image can result in
  355. a more acceptable output. Default values of sharpening can be overridden for
  356. special effects: -sharpen8 does edge detection. Lower amounts of sharpening
  357. are obtained with larger -sharpen numbers. In general the more input and
  358. output pixels and the greater the output range in a pixel in the images, the
  359. less sharpening is required. Sharpening a picture which is already dithered
  360. can give a very bad result....
  361.  
  362. The sharpening is achieved with the following matrix:
  363.  
  364.    -1    -1    -1
  365.    -1 sharpen  -1
  366.    -1    -1    -1
  367.  
  368. ChangeFSI computes the sum of nine pixels with the above weights for each
  369. input pixel and renormalises the result (divides by sharpen-8).
  370.  
  371. An option for testing is "-nodither" which disables the Floyd Steinberg
  372. error diffusion step completely. Versions after 6th June 1990 are more
  373. accurate at doing this.
  374.  
  375. The various processes described above are applied in the following order for
  376. pictures with more output pixels than input:
  377.    (a) range or histogram equalisation,
  378.    (b) sharpen,
  379.    (c) scale,
  380.    (d) error diffusion.
  381. This order is chosen so that:
  382.    (1) since the input pixels (rather than the output pixels) are sharpened,
  383.        there is no false edge introduced when pixels are replicated.
  384.  
  385. The various processes described above are applied in the following order for
  386. pictures with fewer output pixels than input:
  387.    (a) scale,
  388.    (b) range or histogram equalisation,
  389.    (c) sharpen,
  390.    (d) error diffusion.
  391. This order is chosen so that:
  392.    (1) ranging can enhance down-sized images. Say a black/white dithered image
  393.        is reduced in size, so that the output from the scaling process is (some
  394.        approximation to) the original grey levels; then ranging can expand this
  395.        if possible.
  396.    (2) sharpening can be used to offset the blurring effects of scaling.
  397.    (3) since the output pixels (rather than the input pixels) are sharpened,
  398.        the effect of -sharpenN is consistent over differently scaled images.
  399.  
  400. There may be times when this automatic selection of order gets it wrong,
  401. particularly when changing the aspect ratio, it is possible to trigger some
  402. undesirable sharpening artifacts. Use the program twice with with sharpening
  403. (say) disabled and enabled in the order required.
  404.  
  405. Examples of use:
  406.  
  407. Make "standard palette" versions of existing 256 colour images (for example
  408. the Watford digitiser plus colour board doesn't use the standard palette).
  409.   (e.g. "changefsi in out 13p" for a coloured Watford picture)
  410.  
  411. Or convert a colour picture to something you can see on your high res mono
  412. monitor.
  413.   (e.g. "changefsi in out 18 -sharpen -info")
  414.  
  415. Or convert a large monochrome picture (from a scanner, say) to something
  416. which can be seen.
  417.   (e.g. "changefsi in out 20t 1:4 -gamma")
  418.  
  419. Or convert a colour picture to grey scale for the desktop.
  420.   (e.g. "changefsi in out 20")
  421.  
  422. Or change a 512 by 480 image to standard format and aspect ratio
  423.   (e.g. "changefsi in out 15 640:512 512:480")
  424.   (or "changefsi in out = -range")
  425.  
  426. Or change to digital r, g, b
  427.   (e.g. "changefsi in out 20d -sharpen16")
  428.  
  429. Or convert a picture for printing on a 300dpi laser.
  430.   (e.g. "changefsi in out 18c 300:90 -sharpen")
  431.  
  432. And many more uses such as making miniatures of pictures, animated sequences
  433. of pictures changing size (or sharpness!), converting Artisan pictures to
  434. the desktop (try looking at the Artisan Garden with the desktop in 256
  435. colours and ChangeFSI's version - the stripes on the lawn vanish with the
  436. standard version). Obviously you will need to have captured input as a
  437. sprite first! Using more pixels per inch can improve the quality of the
  438. result, particularly converting to multisync modes.
  439.  
  440. Note that, for all work with ChangeFSI, it is a good idea to start from the
  441. unprocessed input each time and do everything in one pass (rather than using
  442. the program several times with simple arguments). It is not a good idea to
  443. sharpen a dithered image (unless it has been shrunk).
  444.  
  445. *** It is a very good idea to keep the highest resolution master that you
  446. can afford the disc space for....
  447.  
  448. The ChangeFSI program can also convert from non RISC OS sprite formats while
  449. doing all of the above processing. ChangeFSI will work out what the format
  450. is automatically. For native RISC OS formats, it uses the filetype and there
  451. can be no confusion. For alien formats, it first tries looking for
  452. particular identifying information inside the file and then (if this fails
  453. to have identified a format) tries using the file name itself. See the
  454. details below:
  455.  
  456. The RISC OS sprite format
  457.  Contains 1, 2, 4 or 8 bits per pixel with a modification palette of up to
  458.  16 entries; any number of pixels wide and high uncompressed. Details are in
  459.  Acorn's Programmer's Reference Manual.
  460.  + Recognised by file type FF9 (a paint brush and house icon)
  461.  - Details of how many bits per pixel and the pixel size are obtained from
  462.    the operating system (rather than being in the file) from the "MODE"
  463.    number. Mode extensions can result in a source image containing a MODE
  464.    number which your computer does not understand.
  465.  
  466. The ArVis format [of ArVis Multimedia]
  467.  Contains 5 bits of red, green and blue information encoded into two RISC OS
  468.  sprites "HIP.<filename>" and "LOP.<filename>" comprising a 640 pixel wide
  469.  and 256 line tall image with pixels sized 1:2. Details from ArVis Multimedia
  470.  - Recognised by providing the HIP.<filename> (which must be of file type FF9)
  471.  - Uncompressed (indeed represents 16 bits instead of 15).
  472.  
  473. The Pineapple colour digitiser format (of Pineapple Software)
  474.  Contains 6 bits of green, 5 bits of red and blue information filed as a
  475.  single data file starting "FSIfile" comprising a 512 pixel wide and 256
  476.  line tall image with pixels sized 1:2.
  477.  - Recognised by "FSIfile" in the file (which can be any type)
  478.  - Uncompressed
  479.  
  480. The Watford Video Digitiser "picture" format
  481.  Contains a run length encoded 64 grey level 512 pixel wide, 256 line image,
  482.  with pixels sized 1:2. Details from Watford Electronics Ltd.
  483.  + Recognised by file type DFA (a small grey picture of Stevie Nicks)
  484.  - Warning: don't forget to save the pictures in *un-dithered* state!
  485.  When used with a colour converter, ChangeFSI can read three colour
  486.  separations stored in a directory of separate "red", "green" and "blue"
  487.  files. Beware of auto-gain/contrast when using such information!
  488.  
  489. The ProArtisan compressed picture file format
  490.  Contains a (mildly) compressed MODE 15 (640 by 256 by 256 colours) picture.
  491.  Details from Clares.
  492.  + Recognised by file type DE2 (a beige monitor in a grey surround)
  493.  
  494. The TimeStep satellite image format
  495.  This gives an uncompressed 800 by 800 with 256 grey levels.
  496.  + Recognised by file type 7A0 (icon never seen)
  497.  - No resolution specified, equal to mode 27 assumed
  498.  - Documentation never seen. An extra header file <name>! is not understood
  499.    at all.....
  500.  
  501. CCIR601 4:2:2 images
  502.  Contain 720 pixels by 288 rows (PAL) [243 rows NTSC] YUV coded with
  503.  pixels sized 1:2.
  504.  + Recognised by file type 601
  505.  - one field only
  506.  
  507. Another TimeStep satellite image format
  508.  Giving an uncompressed 128 pixels wide by 256 lines with 256 grey levels,
  509.  pixels sized 2:1. Used by TimeStep's !ImProcess application.
  510.  + Recognised by file type 300 ("i" in a document frame)
  511.  - Documentation never seen.
  512.  - A bit coarse
  513.  The grey levels represent intensity in various different wave bands. By
  514.  naming files "red", "green" and "blue" and handing ChangeFSI the directory,
  515.  you can produce a false colour image. Hours of experimentation can produce
  516.  an almost reasonable picture...
  517.  
  518. The AIM and Wild Vision V10 format
  519.  This provides an uncompressed 256 by 256 image with 256 grey levels. Details
  520.  from Delft University of Technology and ECD Computers Delft B.V.
  521.  + Recognised by file type 004 (a picture of 'Trui' with "TU" in blue)
  522.  + ChangeFSI can write to this format (specify "aim" in the mode position)
  523.    and specify = in the sizing to get a 256 by 256 output (otherwise it will
  524.    be the same size as the source image)
  525.  - No resolution specified, equal to mode 27 assumed
  526.  - The associated file <name>+ (file type 010) which contains additional
  527.    information is ignored by ChangeFSI.
  528.  The grey levels may represent intensity in various different wave bands. By
  529.  naming files "red", "green" and "blue" and handing ChangeFSI the directory,
  530.  you can produce a false colour image. Hours of experimentation can produce
  531.  an almost reasonable picture...
  532.  
  533. The Wild Vision V12 format
  534.  This provides an uncompressed 512 by 512 image with 256 grey levels.
  535.  + Recognised by file type 006
  536.  - No resolution specified, equal to mode 27 assumed
  537.  
  538. The Wild Vision V9 and SnapShot formats
  539.  This provides an uncompressed 512 by 256 image with 4 bits of red, green
  540.  and blue, pixels sized 1:2.
  541.  + Recognised by "MercSoft" or "SnapShot" header
  542.  + No file type needed
  543.  
  544. The !Translator Clear format
  545.  This provides 1, 2, 4, 8 and 24 bits per pixel.
  546.  + Recognised by file type 690
  547.  - uncompressed, especially for <8 bits per pixel which is recorded at one
  548.    byte per pixel.
  549.  - No resolution specified, equal to mode 27 assumed
  550.  
  551. The Atari ST "Degas" format
  552.  1, 2 or 4 bits per pixel, clear or run length encoded. RISC OS file type by
  553.  John Kortink of !Translator.
  554.  + Recognised by file type 691
  555.  - No documentation and only 5 images read
  556.  - No resolution specified, equal to mode 27 assumed
  557.  
  558. >> All the file formats so far have been designed on RISC OS (or Arthur) and
  559. recognition of the format is defined by file type, the files arrive on RISC
  560. OS floppy discs, and the originators live in the same time zone. For the
  561. following formats many of these things are not true... Which makes it more
  562. difficult to guarantee that ChangeFSI will be able to read the file.
  563.  
  564. The Millipede Prisma format (used by CadSoft also)
  565.  The Millipede Prisma 3 is a 768 pixels wide by 574 line interlaced display
  566.  board for the Archimedes and BBC Microcomputer. It allows use of 256
  567.  colours from 2^24. Files may be stored uncompressed (432KBytes!) or run
  568.  length encoded. More details from CadSoft or Millipede Electronic Graphics.
  569.  + Recognised by "MILLIPEDE" at offset 16 in the file
  570.  - No resolution specified, equal to mode 27 assumed
  571.  - slowish to read the compressed formats
  572.  - scaling the picture using = can be poor since 574 lines don't relate very
  573.    well to 512 or 256. Use -info to display the scale ratios.
  574.  
  575. The Aldus/MicroSoft TIFF format (also filetype FF0 is assigned to TIFF)
  576.  Frequently used by scanners, TIFF is a common interchange format for
  577.  graphics images on the Mac and PC (particularly DTP and Windows). It
  578.  provides an arbitrary number of bits per pixel, size etc using a numeric tag
  579.  scheme allowing new information to be introduced without upsetting existing
  580.  programs. The format may be compressed (in 5 different ways at present).
  581.  Details from Aldus UK, MicroSoft, Hewlett Packard...
  582.  + Recognised by file type FF0
  583.  + Recognised by "II" plus the 16 bit number 42 at the start of the file for
  584.    little endian machines (ix86, ARM, VAX...)
  585.  + Recognised by "MM" plus the 16 bit number 42 at the start of the file for
  586.    big endian machines (M680x0...)
  587.  + Can read PackBits images and LZW compressed forms (at least the 3 its
  588.    seen so far...)
  589.  - Cannot read predictor compressed LZW images.
  590.  - So far ChangeFSI has only done 1, 4, 8 and 24 bit images.
  591.    It can't read "planar" images or CCITT compressed forms.
  592.  - Some TIFF images have incorrect pixel sizes: use -nosize if this is
  593.    true. If no pixel size is specified, ChangeFSI assumes mode 27 size.
  594.  
  595. The CompuServe GIF format
  596.  Used for wide area network transfer of images. It provides an LZW
  597.  compressed up to 256 colours from 2^24 arbitrary sized image. Details from
  598.  CompuServe (USA) [or usenet]
  599.  + Recognised by "GIF87a" at the start of the file
  600.  + LZW compression is efficient even for dithered images
  601.  + ChangeFSI can decompress LZW quickly
  602.  - No resolution specified, equal to mode 27 assumed
  603.  - many low quality images around from PCs
  604.  
  605. The Electronic Arts IFF ILBM format
  606.  Provides an arbitrary sized image with up to 4096 colours sometimes run
  607.  length encoded. ChangeFSI understands the generic format and also the
  608.  special Amiga format for "HAM" and "Half-bright" images.
  609.  + Recognised by "FORM" as the first four characters and "ILBM" as
  610.    characters 8 to 11
  611.  - Only pixel aspect ratio specified, not its size (and then sometimes
  612.    incorrectly): use -nosize *and* a size change (a:b) if its wrong
  613.  - images often small
  614.  - doesn't understand Amiga "hires"
  615.  - can't convert HAM pictures directly to monochrome
  616.  
  617. The MicroSoft Windows 3 .BMP format
  618.  Used by MicroSoft in Windows 3 and PaintBrush for Windows 3. Provides an
  619.  arbitrary sized image and 1, 4 or 8 bits per pixel. Uncompressed.
  620.  + Recognised by "BM" as the first two characters
  621.  - No resolution specified, equal to mode 27 assumed
  622.  - documentation never seen - 7 files examined and intelligent guesses made!
  623.  
  624. The Digital Research GEM .IMG format
  625.  Used by GEM (and GEM Paint) on both PC and Atari ST. Provides an arbitrary
  626.  sized image and number of bits per pixel (though its only usually used with
  627.  up to 5 bits per pixel) and pixel size. Compressed by run length encoding
  628.  and line repeats.
  629.  - Recognised by 00 01 00 08 as the first four bytes ("version 1, header
  630.    length 8") or by "IMG" as the name of the directory the file is in.
  631.  - Planar file format slow to read
  632.  - Palette not specified: ChangeFSI assumes linear shades of grey. You might
  633.    need to use -invert if the image is a negative
  634.  - The size of a pixel is specified in microns. The standard RISC OS 90
  635.    pixels per inch translates to (1/90*2.54*10,000) microns - 282. (use
  636.    -info to get information about the scaling, -nosize to stop it)
  637.  - Documentation from the "ST World" magazine's clinic.
  638.  
  639. An unknown PC .PIC format
  640.  Used for some VGA demos, the format provides an uncompressed 320 by 200 by
  641.  256 colour (from 2^24) VGA screen dump.
  642.  + Recognised by "AV_VO" as the first five bytes in the file
  643.  - Documentation never seen
  644.  - Pixel size assumed the same as MODE 13 (45 pixels per inch).
  645.  
  646. The MacPaint format
  647.  Provides a 576 by 720 bitmap, run length coded by the Mac's "PackBits"
  648.  algorithm (repeated bytes).
  649.  - Recognised by "PNTG" at position 65 in the file. This may only relate to
  650.    files which have been through a program called "MacFix". Data assumed to
  651.    start at position 128 in the file. Header ignored.
  652.  - No resolution specified, equal to mode 25 assumed
  653.  
  654. The ZSoft .PCX format
  655.  Used by PC Paintbrush. Usually a 4 bit per pixel image (CGA, EGA, VGA) but
  656.  can be 1-8 bits per pixel.
  657.  - Recognised by 10,[0,2,3,4,5],1 at start of file. Or by name PCX.<foo>
  658.  + Intelligent check for resolution of the DACs on the PC card. Use -info to
  659.    find out what ChangeFSI thinks it is.
  660.  + Pixel size information read. You may need to stop the scaling with
  661.    -nosize, since its often wrong.
  662.  
  663. The RIX Softworks ColoRIX format
  664.  Used by VGA Paint, image extension .SCE .. .SCX. 4 or 8 bits per pixel.
  665.  - Recognised by "RIX3" at start of file
  666.  - Documentation never seen
  667.  - Only 5 files read: ChangeFSI checks to see if the header is the same
  668.    as these files and complains otherwise.
  669.  - No resolution specified, equal to mode 27 assumed
  670.  
  671. The Sun "pixrect" format
  672.  Used under SunOS and also under X11. Commonly 1 or 8 bits per pixel, but up
  673.  to 24 bits per pixel can be found (see the Sun NeWS release tape!).
  674.  + Recognised by &59A55A95 at the start of the file.
  675.  - No resolution specified, equal to mode 27 assumed
  676.  - Sun didn't specify the pixel ordering of 24 bit per pixel images: many
  677.    assume RGB when it was actually BGR. Change byte &17 in the Sun
  678.    rasterfile between 1 and 3 if you have a problem.
  679.  
  680. The "pbm" 'portable bitmap' file format
  681.  Used by the "PBM-PLUS" toolkit (mainly Unix) by Jef Poskanzer. 1-24 bits
  682.  per pixel (more can be specified in the format but ChangeFSI cannot read
  683.  them). ChangeFSI can only read the "RAWBITS" formats (it can write all of
  684.  the pbm formats).
  685.  + Recognised by P4/P5/P6 at start of file.
  686.  + Writable by ChangeFSI
  687.  - No resolution specified, equal to mode 27 assumed
  688.  
  689. The UNIX "rle" format
  690.  Used by a program called "svfb" to save the contents of large frame
  691.  buffers, checked with four images at 24 bits per pixel.
  692.  + Recognised by &CC52 at the start of the file.
  693.  - No resolution specified, equal to mode 27 assumed
  694.  
  695. The TrueVision Targa format
  696.  Used by TrueVision for Vista boards. Up to 32 bits per pixel.
  697.  - Recognised by suffix _TGA or _VDA on the name.
  698.  - Only uncompressed formats readable.
  699.  - Only 8 and 16 bit per pixel formats tested.
  700.  
  701. The "Flexible Image Transport System" (FITS) format
  702.  Used for astronomical data. Up to 16 bits per pixel component.
  703.  + Recognised by "SIMPLE" at the start of the file.
  704.  - Only 8 and 16 bit per pixel component formats tested.
  705.  - Only two files ever seen!
  706.  - No resolution specified, equal to mode 27 assumed
  707.  
  708. The Irlam instruments colour scanner format
  709.  24 bit per pixel from colour scanner.
  710.  + Recognised by Irlam 24 at the start of the file.
  711.  + Writable by ChangeFSI
  712.  - No resolution specified, equal to mode 27 assumed
  713.  - may need gamma correction
  714.  
  715. The Irlam instruments YUV 411 colour video format
  716.  7 bits Y, up to 7 bits U and V.
  717.  + Recognised by Irlam YUV 411 at the start of the file
  718.  - no resolution specified, equal to mode 27 assumed
  719.  
  720. The JPEG 'JFIF' File Interchange Format
  721.  Up to 24 bits R,G,B, compressed by the JPEG compression system.
  722.  + Recognised by JFIF at position 6 in the file (you may have to
  723.    cut headers off files, particularly oif they are from Macs).
  724.  + Often highly compressed
  725.  - ... and therefore slow. Needs a lot of space in <Wimp$Scrap>.
  726.  - ChangeFSI calls a djpeg routine. This can be on the Run$Path, implemented
  727.    as an Alias (in which case it *must* use WimpTask to start) or found
  728.    inside ChangeFSI$Dir if all else fails. cjpeg (the compressor) is also
  729.    available inside ChangeFSI$Dir - you will need to convert the image to
  730.    P6 format before it can be compressed. Djpeg and cjpeg are by the
  731.    PD JPEG group.
  732.  - no resolution specified, equal to mode 27 assumed
  733.  
  734. >> The following file formats are only recognised by their names.
  735.  
  736. An unknown PC .DSP format
  737.  Experimentally determined that it holds a 640 by 350 EGA picture at 4 bits
  738.  per pixel. ChangeFSI "knows" the default EGA palette (from IBM literature).
  739.  - Recognised by being in a directory "DSP"
  740.  - Documentation never seen
  741.  - No resolution specified, equal to mode 27 assumed
  742.  - Only two examples read(!)
  743.  
  744. The QRT .raw format
  745.  Output from Steve Koren's public domain ray tracer: arbitrary size in 2^24
  746.  colours, uncompressed. Documentation part of QRT.
  747.  - Recognised by the name ending ".Raw"
  748.  - No resolution specified, equal to mode 27 assumed
  749.  
  750. The MTV pic. format
  751.  Output from Mark Terrence VandeWettering public domain ray tracer arbitrary
  752.  size in 2^24 colours, uncompressed. Documentation part of MTV. Also used by
  753.  "RayShade".
  754.  - Recognised by being in a directory "Pic."
  755.  - No resolution specified, equal to mode 27 assumed
  756.  
  757. The RT image. format
  758.  Output from "RT", a private ray tracer by Brian D Watt(?) arbitrary size in
  759.  2^24 colours, run length encoded.
  760.  - Recognised by being in a directory "Image."
  761.  - No resolution specified, equal to mode 27 assumed
  762.  
  763. For many of these formats, especially the uncompressed ones, setting the
  764. variable "ChangeFSI$Cache" to the number of bytes of temporary memory you
  765. wish the program to use will speed up reading the information. The default
  766. is 8192 bytes. For example "*set ChangeFSI$Cache 40k". For those worried
  767. about speed, the program will go faster if:
  768.  
  769.  - you use -noscale and keep 1:1 ratios (don't specify them)
  770.    (although -nosize and 1:1 or 1:2 ratios are quick, too)
  771.  - you don't need sharpening, histogram equalisation, range expansion
  772.  - you use monochrome (e.g. 25, 26, 27 and 27t) modes
  773.  
  774. additionally you can disable dithering (-nodither) especially when reading
  775. monochrome source.
  776.  
  777. You can avoid the program changing mode by putting -nomode on the command line.
  778.  
  779. Very large output files can be built strips at a time and sent directly to
  780. disk using the parameter "-max" e.g:
  781.  
  782.   ChangeFSI <in> <out> 28 -max512K
  783.  
  784. will convert the file with a maximum of 512KBytes held in memory. Options
  785. 25t, -rotate and -vflip don't work when this is being done.
  786.  
  787. Work will be done on other formats when and if both image and documentation
  788. arrive on my desk. Adding a new format is a matter of (a) putting in
  789. automatic recognition of the format at the start of the program (b) reading
  790. the size of the image and the colour palette mapping [in the next section of
  791. the program] (c) writing a "read pixel row" element inside PROCiprow (d)
  792. providing an entry in PROCrewind. If you write a new format interface,
  793. please send it to me so that it will be included in later versions.
  794. ChangeFSI has already got code for dealing with images with 1, 2, 4 and 8
  795. bits per pixel packed into bytes and for images with up to 8 bit planes.
  796. There is support code for LZW decompression and LZW decoding.
  797.  
  798. As a special feature, ChangeFSI will also write out 256 grey level files
  799. (alter rwt, gwt and bwt to get 256 level colour separations) in AIM format.
  800. This is file type 4 with bytes representing the grey level. Use the =
  801. operation to restrict the picture to 256x256y, otherwise it will be the same
  802. size as the input. Specify "aim" as the mode string to do this.
  803.  
  804. For portability to other machines, ChangeFSI can write out files in "pbm"
  805. format. There are 3 types of format "black/white" (pbm), "grey" (pgm) and
  806. "colour" (ppm) with pure ASCII and binary encodings of each:
  807.  
  808. ASCII                                   Binary
  809. p1        "black/white" (like mode 18)  p4 (big endian bytes!)
  810. p2        "grey" (like mode 20t)        p5
  811. p3        "true colour"                 p6
  812.  
  813. Files can be read with Jef Poskanzer's portable toolkit on other machines.
  814. The p2 format is easily convertible by programmers; it consists of:
  815.  
  816. P2
  817. # comment line
  818. xsize ysize
  819. maximum_value
  820. pixel_value <whitespace> pixel_value
  821.  
  822. where all the numbers are in decimal (ASCII). 0 means black, maximum_value
  823. (= 15) means white. The p3 format is similar with r, g, b triples for each
  824. pixel value. The number of bits per component (default 8) can be set from
  825. the command line with, for example, "p3,4" for 4 bits per component.
  826.  
  827. As a special packed output format, "P15" has been implemented. Output is
  828. binary pixel values, 5 bits per component, little endian RGB order packed
  829. into 16 bits. Header information as the other p formats.
  830.  
  831. ChangeFSI can write Irlam format images (somewhat slower than p6 images...).
  832.  
  833.                               Output summary
  834.                               ==============
  835.  
  836. # cols   Colour Cube  Bits used  Consistent Hue  Desktop Palette  Mode&Suffix
  837.  
  838. 2^24            Y         24           Y             -            p3 or p6 or                                                                  Irlam
  839. 2^21            Y         21           Y             -            p6,7
  840. 2^18            Y         18           Y             -            p6,6
  841. 2^15            Y         15           Y             -            p15 or p6,5
  842. 2^12            Y         12           Y             -            p6,4
  843. 512             Y          9           Y             -            p6,3
  844. 256 grey        n          8           Y             -            aim
  845. 256 grey        n          8           Y             -            28d
  846. 256             Y          8           Y             Y            28
  847. 256             Y          8           Y             Y            28t
  848. 256             Y          8           Y             Y            28r
  849. 16 grey         n          4           Y             n            27t
  850. 16 grey         n          4           Y             n            p2 or p5
  851. 8 grey          n          3           Y             Y            27
  852. 16              ?          4           ?             Y            27r
  853. 16              Y          3           Y           can be         27d
  854. 4 grey          n          2           Y             Y            26
  855. 4               n          2           n             n            26c
  856. 4               n          2           n             n            26r
  857. 2 (black/white) n          1           Y             Y            25
  858. 2 (black/white) n          1           Y             Y            25c/d/t
  859. 2 (black/white) n          1           Y             Y            p1 or p4
  860.  
  861.  
  862. ChangeFSI can be used from both the desktop front end and from the command
  863. line. It can also be used as a BASIC library function:
  864. LIBRARY"<ChangeFSI$Dir>.ChangeFSI" gives a new function, FNChangeFSI to the
  865. BASIC programmer. This function takes:
  866.   A$: a command line argument
  867.   spritearea%: an address or -1 for the spritearea built by ChangeFSI
  868.   workspace%: an address or -1 for ChangeFSI's other workspace
  869.   worklimit%: an address (unused if workspace%<0)
  870.   fast%: TRUE for MODE 0 selection
  871. It produces an error (to whatever error handler is present) if it fails. If
  872. spritearea% is <0 it will save the sprite to the file given in the command
  873. string, otherwise it won't. The function FNChangeFSIVersion returns the
  874. version string of the library (in the info box of the desktop application).
  875.  
  876.                            Command Summary
  877.                            ===============
  878.  
  879. -info     give details
  880.  
  881. -hist     don't process image, but display histogram of it instead
  882.  
  883. -hflip    horizontally flip the image
  884. -vflip    vertically flip the image
  885. -rotate   rotate the image by +90 degrees (i.e. anti-clockwise)
  886. -rotate-  rotate the image by -90 degrees (i.e. clockwise)
  887. -max      set the maximum size of the image before disc is used
  888.  
  889. -noscale  disable automatic pixel size correction
  890. -nosize   disable automatic pixel size correction for input pixels only
  891. -nodither disable dithering
  892. -nomode   don't change to mode 0 while processing the picture
  893. -invert   invert colour range of image
  894.  
  895. -range    expand input's dynamic range to full scale
  896. -equal    histogram equalisation
  897. -sharpen  digitally sharpen the picture
  898.  
  899. -gamma    set gamma correction
  900. -black    correct for black ink spot size
  901. -red      change red weight for deriving monochrome luminance
  902. -green    change green weight for deriving monochrome luminance
  903. -blue     change blue weight for deriving monochrome luminance
  904.  
  905. -brighten horrendous hack to slightly brighten images: may convert hues
  906.           close to white to white. (It causes the output range 0..15 to
  907.           be considered as 0..(15/16) instead of 0..(15/15)).
  908.  
  909.                            Mode Suffixes
  910.                            =============
  911.  
  912. c
  913.   1 bit modes: use clustered dithering with 4x4 cell
  914.   2 bit modes: use the four colours "black", "cyan", "magenta" and "yellow"
  915. d
  916.   1 bit modes: use clustered dithering with 2x2 cell
  917.   4 bit modes: use 1 bit red, 1 bit green, 1 bit blue
  918.   8 bit modes: use 256 level grey scale
  919. t
  920.   1 bit modes: use clustered dithering with 3x3 cell
  921.   4 bit modes: 16 level grey scale
  922.   8 bit modes: use table driven selection
  923. r
  924.   2 bit modes: Roger Wilson's (me) colour matching algorithm
  925.   4 bit modes: Roger Wilson's (me) colour matching algorithm
  926.   8 bit modes: Roger Wilson's (me) colour matching algorithm (SLOW!)
  927. -no suffix-
  928.   1 bit modes: b/w dispersed dot dithering
  929.   2 bit modes: 4 level grey scale
  930.   4 bit modes: 8 level grey scale
  931.   8 bit modes: John Bowler's colour matching algorithm
  932.  
  933. Colour matching is done in r, g, b space: the minimum distance between
  934. colours is the square root of:
  935.    delta_r^2*rmatchwt+delta_g^2*gmatchwt+delta_b^2*bmatchwt
  936. ChangeFSI has hard wired weights of 3, 10, 1 respectively for its colour
  937. matching algorithms. John Bowler's algorithm (default for RISC OS 8 bit
  938. modes) although somewhat slower, is fast enough to have replaced all the
  939. previous methods [ASIDE it gives pictures at least as good as "p" mode in
  940. pre Aug 91 ChangeFSI's]. Roger Wilson's (i.e. my) colour matching algorithm
  941. is too slow in 8 bit modes to be recommended, but it is used automatically
  942. if the PCATS Graphics Enhancer is in use: the colour set for output is not
  943. the RISC OS colour set.
  944.  
  945. [NOTE: thanks are due to Steve Green and the BBC and Irlam Instruments for
  946. the intermediate systems that led to John Bowler's and my algorithms: until
  947. Aug 91 ChangeFSI used their work for its "Precise Matching" algorithm. It no
  948. longer uses any of their code, but owes a debt for overall approach.]
  949.  
  950. The 8 bit mode t algorithm requires a 4096 entry lookup table indexed by 4
  951. bits of r, g, b information with r as the bottom 4 bits, g as the next 4, b
  952. as the top 4 bits. The table yields a byte which is the colour to use.
  953. Immediately following this table are 256 32 bit words of form BBGGRRxx which
  954. give the outputs for each input colour. The program loads the table as
  955. <ChangeFSI$Dir>.CFSIict.
  956.  
  957. Further information on dithering can be found in "Digital Halftoning" by
  958. Robert Ulichney published by the MIT Press, ISBN 0-262-21009-6. A book which
  959. I wish I'd had when I started writing the program, rather than after it was
  960. nearly finished! Histogram equalisation is in "Algorithms for Graphics and
  961. Image Processing" by Theo Pavlidis published by Computer Science Press, ISBN
  962. 0-914894-65-X.
  963.